// 引入 request 方法，假设 request 方法已经定义在某个工具文件中
import request from '/@/utils/request';
import  { StatusEnum } from '../enum';
// 定义 API 路径枚举
enum Api {
    SysRoleAdd = '/sysRole/AddRole',
    SysRoleDelete = '/sysRole/DeleteRole',
    SysRoleGrantDataScope = '/sysRole/grantDataScope',
    SysRoleGrantMenu = '/sysRole/grantMenu',
    SysRoleList = '/sysRole/list',
    SysRoleOwnMenuList = '/sysRole/ownMenuList',
    SysRoleOwnOrgList = '/sysRole/ownOrgList',
    SysRolePage = '/sysRole/page',
    SysRoleSetStatus = '/sysRole/setStatus',
    SysRoleUpdate = '/sysRole/UpdateRole',
    GrantMenu = '/sysRole/GrantMenu',
}

// 定义 API 方法
export const apiSysRoleAddPost = (body?: any) =>
    request({
        url: Api.SysRoleAdd,
        method: 'post',
        data: body,
    });

export const apiSysRoleDeletePost = (body?: any) =>
    request({
        url: Api.SysRoleDelete,
        method: 'delete',
        data: body,
    });

export const apiSysRoleGrantDataScopePost = (body?: any) =>
    request({
        url: Api.SysRoleGrantDataScope,
        method: 'post',
        data: body,
    });

export const apiSysRoleGrantMenuPost = (body?: any) =>
    request({
        url: Api.SysRoleGrantMenu,
        method: 'post',
        data: body,
    });

    export const apiGrantMenuPost = (body?: any) =>
        request({
            url: Api.GrantMenu,
            method: 'post',
            data: body,
        });
    
export const apiSysRoleListGet = () =>
    request({
        url: Api.SysRoleList,
        method: 'get',
    });

export const apiSysRoleOwnMenuListGet = (id: number, status?: StatusEnum) =>
    request({
        url: `${Api.SysRoleOwnMenuList}?Id=${id}&Status=${status ?? ''}`,
        method: 'get',
    });

export const apiSysRoleOwnOrgListGet = (id: number, status?: StatusEnum) =>
    request({
        url: `${Api.SysRoleOwnOrgList}?Id=${id}&Status=${status ?? ''}`,
        method: 'get',
    });

export const apiSysRolePagePost = (body?: any) =>
    request({
        url: Api.SysRolePage,
        method: 'post',
        data: body,
    });

export const apiSysRoleSetStatusPost = (body?: any) =>
    request({
        url: Api.SysRoleSetStatus,
        method: 'post',
        data: body,
    });

export const apiSysRoleUpdatePost = (body?: any) =>
    request({
        url: Api.SysRoleUpdate,
        method: 'put',
        data: body,
    });